;;; packages.el --- hesperus layer packages file for Spacemacs.
;;
;; Copyright (c) 2012-2018 Sylvain Benner & Contributors
;;
;; Author: Hesperus <hesperus@Archer>
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; This file is not part of GNU Emacs.
;;
;;; License: GPLv3

;;; Commentary:

;; See the Spacemacs documentation and FAQs for instructions on how to implement
;; a new layer:
;;
;;   SPC h SPC layers RET
;;
;;
;; Briefly, each package to be installed or configured by this layer should be
;; added to `hesperus-packages'. Then, for each package PACKAGE:
;;
;; - If PACKAGE is not referenced by any other Spacemacs layer, define a
;;   function `hesperus/init-PACKAGE' to load and initialize the package.

;; - Otherwise, PACKAGE is already referenced by another Spacemacs layer, so
;;   define the functions `hesperus/pre-init-PACKAGE' and/or
;;   `hesperus/post-init-PACKAGE' to customize the package as it is loaded.

;;; Code:

(defconst hesperus-packages
  '(
    ;; beacon
    diff-hl
    electric-operator
    multiple-cursors
    nov
    ;; pangu-spacing
    rainbow-mode
    )
  "The list of Lisp packages required by the hesperus layer.

Each entry is either:

1. A symbol, which is interpreted as a package to be installed, or

2. A list of the form (PACKAGE KEYS...), where PACKAGE is the
    name of the package to be installed or loaded, and KEYS are
    any number of keyword-value-pairs.

    The following keys are accepted:

    - :excluded (t or nil): Prevent the package from being loaded
      if value is non-nil

    - :location: Specify a custom installation location.
      The following values are legal:

      - The symbol `elpa' (default) means PACKAGE will be
        installed using the Emacs package manager.

      - The symbol `local' directs Spacemacs to load the file at
        `./local/PACKAGE/PACKAGE.el'

      - A list beginning with the symbol `recipe' is a melpa
        recipe.  See: https://github.com/milkypostman/melpa#recipe-format")

;; (defun hesperus/init-ace-pinyin ()
;;   (use-package ace-pinyin
;;     :defer t
;;     :init
;;     ;; (setq ace-pinyin-use-avy nil) ;; uncomment if you want to use `ace-jump-mode
;;     (ace-pinyin-global-mode +1)
;;     ;; (setq ace-pinyin-simplified-chinese-only-p nil)
;;     ))

;; (defun hesperus/init-beacon ()
;;   "Initialize beacon"
;;   (use-package beacon
;;     :init
;;     (beacon-mode 1)
;;     (setq beacon-color "#827100")))

(defun hesperus/init-diff-hl ()
  (use-package diff-hl
    :defer t
    :init
    (setq diff-hl-fringe-bmp-function 'diff-hl-fringe-bmp-from-type)
    (global-diff-hl-mode)))

(defun hesperus/init-electric-operator ()
  (use-package electric-operator
    :defer t
    :hook ((cperl-mode python-mode) . electric-operator-mode)))

(defun hesperus/init-multiple-cursors ()
  (use-package multiple-cursors
    :defer t
    :diminish
    :init
    (bind-key* "C-S-c" 'mc/edit-lines)
    (bind-key* "C->" 'mc/mark-next-like-this)
    (bind-key* "C-<" 'mc/mark-all-words-like-this-in-defun)
    ;; better use with expand-region
    (bind-key* "C-=" 'er/expand-region)))

(defun hesperus/init-nov ()
  (use-package nov
    :defer t
    :init
    (add-to-list 'auto-mode-alist '("\\.epub\\'" . nov-mode))))

;; (defun hesperus/init-pangu-spacing ()
;;   (use-package pangu-spacing
;;     :defer t
;;     :init
;;     (global-pangu-spacing-mode 1)
;;     ;; (setq pangu-spacing-real-insert-separtor t)
;;     (defcustom pangu-spacing-inhibit-mode-alist '(eshell-mode shell-mode term-mode yaml-mode)
;;       "Inhibit mode alist for pangu-spacing-mode."
;;       :group 'pangu-spacing
;;       :type 'list)))

(defun hesperus/init-rainbow-mode ()
  ;; Colorize color names in buffers
  (use-package rainbow-mode
    :defer t
    :diminish
    :hook ((emacs-lisp-mode web-mode css-mode ess-r-mode) . rainbow-mode)))

;;; packages.el ends here
